import requests
from config import url_cloud, headers_web


class ClassRooms:
    def __init__(self):
        self.url = url_cloud
        self.headers = headers_web

    @classmethod
    def get_all_buildings_info(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:查询所有楼栋信息
        @description:小程序教室预约调用
        :param url_path:
        :param headers:
        :param params:validCode:验证码&signKey=123123(md5加密)
        :return:object{
                        "categoryName":"", # 楼栋名称
                        "checked":"", # 是否勾选
                        "id":"" # 楼栋id
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/buildings"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_classroom_info_ip_or_mac(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据ip地址或mac地址获取教室信息
        @description:小程序教室预约调用
        :param url_path:
        :param headers:
        :param params:{
                        "ip":"", # ip地址
                        "mac":"", # mac地址
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        :{
                        "centerId":"",
                        "centerName":"",
                        "roomId":"",
                        "roomIng":"",
                        "roomLat":"",
                        "roomName":"",
                        "seatNum":""
                        }}
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_classroom_info_for_buildid(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据楼栋Id获取开启教室预约教室下的教室信息(包含没有任何设备的教室)
        @description:课堂老师小程序端——教室预约
        :param url_path:
        :param headers:
        :param params:{
                        "buildingId":"", # 楼栋Id
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "roomCode":"", # 教室编号
                        "roomId":"", # 教室id
                        "roomName":"" # 教室名称
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/appointmentbuildingclassroom"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_classroom_info_for_buildname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称获取教室预约教室下的教室信息(包含没有任何设备的教室)
        @description:云课堂管理web端、老师web端——教室预约
        :param url_path:
        :param headers:
        :param params:{
                        "classroomName":"", # 教室名称
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomNo":"", # 教室名称
                        "roomName":"" # 教室编号
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/appointmentclassroomanddevice"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r


    @classmethod
    def get_all_classrooms_info(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:查询所有的教室信息以及级联信息
        @description:查询所有的教室信息以及级联信 1.三画面下载使用
        :param url_path:
        :param headers:
        :param params:validCode:验证码&signKey=123123(md5加密)
        :return:{
                        "classroomAppointmentStatus":"", # 启教室预约状态：true：开放教室预约，false：不开放教室预约
                        "classroomStatus":"", # 是否启用
                        "floorId":"" # 楼层id
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/cascade"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_all_devices_info_for_buildname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称获取教室及教室下的设备信息(包含没有任何设备的教室)
        @description:云课堂管理端、老师端活动预约使用
        :param url_path:
        :param headers:
        :param params:{
                        "classroomName":"", #教室名称
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomNo":"", # 教室名称
                        "roomName":"" # 教室编号
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/classroomsAndDevices"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_devices_info_for_buildname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称获取教室及教室下的设备信息
        @description:云课堂管理端自定义录制任务使用
        :param url_path:
        :param headers:
        :param params:{
                        "classroomName":"", #教室名称
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomNo":"", # 教室名称
                        "roomName":"" # 教室编号
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/devices"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_statistics_classroom_device(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取所有教室设备类型对应总数
        @description:大数据 - 获取对应类型下设备总数接口
        :param url_path:
        :param headers:
        :param params:validCode:验证码&signKey=123123(md5加密)
        :return:object{
                        "deviceAmount":"", # 设备总数
                        "deviceTypeId":"", # 设备类型id
                        "deviceTypeName":"" #设备类型名称
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/devicetypestatistics"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_entrance_info_for_buildname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取所有教室设备类型对应总数
        @description:大数据 - 获取对应类型下设备总数接口
        :param url_path:
        :param headers:
        :param params:{
                        "classroomName":"", #教室名称
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomNo":"", # 教室名称
                        "roomName":"" # 教室编号
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/entranceguard"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_all_entrance_info_for_buildname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取所有教室设备类型对应总数
        @description:大数据 - 获取对应类型下设备总数接口
        :param url_path:
        :param headers:
        :param params:"validCode":"" # 验证码&signKey=123123(md5加密)
        :return:object:{
                        "roomId":"", # 教室id
                        "seatNum":"", # 座位数
                        "roomName":"" # 教室名称
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/entranceguardstatus"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_all_classroom_type(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取所有的教室类型
        @description:需要根据教室类型查询的页面使用
        :param url_path:
        :param headers:
        :param params:"validCode":"" # 验证码&signKey=123123(md5加密)
        :return:object:{
                        "id":"", # id
                        "typeCode":"", # 类型码
                        "typeName":"" # 类型名称
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/getroomtypes"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_all_classroom_info(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室Id查询所有的教室信息
        @description:云课堂接口查询实验室容量信息
        :param url_path:
        :param headers:
        :param params:{
                        "ids":"", #实验室Id，多个用，分割
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "appointmentCapacity":"", # 容量
                        "id":"" # id
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/ids"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    def get_entrance_info_for_ids(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称或编号和教室id获取教室及教室下的门禁信息
        @description:云课堂管理端门禁临时授权使用
        :param url_path:
        :param headers:
        :param params:{
                        "roomIds":"", 教室id(逗号隔开)
                        "validCode":"", # 验证码&signKey=123123(md5加密)
                        "roomNameOrCode":"" # 教室名称或编号
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomName":"", # 教室名称
                        "roomNo":"", # 教室编号
                        "smartDevice":[{
                            "deviceIP":"", # 终端IP
                            "deviceName":"", # 终端名称
                            "deviceNo":"", # 设备编号
                            "deviceType":"", # 终端类型(1-门禁机，2-电子班牌)
                            "id":"", # 终端类型(1-门禁机，2-电子班牌)
                            "onlineStatus":"" #在线状态 (0-离线，1-在线)
                            }]
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/permissions/entranceguard"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_query_entrance_info_for_all(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称或编号精确查找教室及教室下的门禁信息
        @description:小程序管理端门禁综合查询使用
        :param url_path:
        :param headers:
        :param params:{
                        "validCode":"", # 验证码&signKey=123123(md5加密)
                        "roomNameOrCode":"" # 教室名称或编号
                        }
        :return:object:{
                        "id":"", # 教室id
                        "roomName":"", # 教室名称
                        "roomNo":"", # 教室编号
                        "smartDevice":[{
                            "deviceIP":"", # 终端IP
                            "deviceName":"", # 终端名称
                            "deviceNo":"", # 设备编号
                            "deviceType":"", # 终端类型(1-门禁机，2-电子班牌)
                            "id":"", # 终端类型(1-门禁机，2-电子班牌)
                            "onlineStatus":"" #在线状态 (0-离线，1-在线)
                            }]
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/permissions/entranceguard/acc"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_classroom_info_for_roomname(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:根据教室名称或编号精确查找教室及教室下的门禁信息
        @description:小程序管理端门禁综合查询使用
        :param url_path:
        :param headers:
        :param params: {
                        "validCode":"", # 验证码&signKey=123123(md5加密)
                        "roomName":"" # 房间名称
                        }
        :return:object:{
                        "categoryName":"", # 房间级联名称（>拼接，最高到校区，最低到楼层）
                        "roomCode":"", # 房间编号
                        "roomId":"", # 房间id
                        "roomName":"" # 房间名称
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/roominfos"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_statistics_classroom_counts(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取对应类型下教室数量接口
        @description:大数据 - 获取对应类型下教室数量接口
        :param url_path:
        :param headers:
        :param params:validCode:验证码&signKey=123123(md5加密)
        :return:object:{
                        "counts":"", # 相关类型教室总数
                        "roomTypeId":"", # 教室类型id
                        "roomTypeName":"" # 教室类型id
                        }
        """
        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/roomtypecounts"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_classroom_info(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:查询教室信息
        @description:二次排课查询教室信息,服务内部调用
        :param url_path:
        :param headers:
        :param params:{
                        "roomIds":"", # 教室ids，多个使用逗号隔开
                        "validCode":"" # 验证码&signKey=123123(md5加密)
                        }
        :return:object:{
                        "classroomAppointmentStatus":"", # 启教室预约状态：true：开放教室预约，false：不开放教室预约
                        "classroomStatus":"", # 是否启用
                        "floorId":"", # 楼层id
                        "floorName":"", # 所属楼层名称
                        "frontSeatNum":"", # 前排座位数
                        "hasLive":"", # 能否直播
                        "id":"", # id
                        "isLaboratory":"", # 是否是实验室
                        "parentId":"", # 父级id（一级节点：root）
                        "roomCode":"", # 教室编号
                        "roomId":"", # 教室id
                        "roomName":"", # 教室名称
                        "roomShowOrder":"", # 教室排序字段
                        "roomType":"", # 教室类型
                        "roomTypeName":"",# 教室类型名称
                        "seatNum":"",# 座位数
                        "showOrder":"" # 顺序
                        }
        """

        url_path = url_path + "/ICloudClassroomDev/api/v1/classrooms/search"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r